package com.qian.ddj.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.qian.api.ddj.model.Withdraw;
import com.qian.api.ddj.service.IBusinessService;
import com.qian.api.ddj.service.IWithdrawService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Slf4j
@Controller
@RequestMapping("/ddj/withDrawNotify")
public class withDrawNotifyController {
    @Autowired
    private IWithdrawService withdrawService;
    @Autowired
    private IBusinessService businessService;

//    @RequestMapping("/easyPayNotify")
//    public void easyPayNotify(HttpServletRequest request, final HttpServletResponse response){
//        ApiClient apiClient = ApiClientFactory.newClient("https://gw.ak47pay.com/native/", "FUAR24001ZZAO", "2017102916590427001");
//        apiClient.callback4Trade(request, response, new AbstractCallbackHandler4Trade() {
//            @Override
//            public void paySucceed(JSONObject jdata) {
//                Withdraw withdraw = withdrawService.findByOrderNo(jdata.getString("outTradeNo"));
//                withdrawService.success(withdraw.getId());
//                try {
//                    response.getWriter().write("SUCCESS");
//                } catch (IOException e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public void payFailed(JSONObject jdata) {
//
//            }
//        });
//    }
}
